package com.ottoman.snackgames;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;



public class MazeWorld {
	private World world;
    public final float PIX_TO_METER = 0.0025f;
    public final float METER_TO_PIX = 400;

    public void setWorld(World w){
		world = w;
	}
    
    public Vector2 toScreen(Vector2 pos){
		pos.x = pos.x  * METER_TO_PIX;
		pos.y = pos.y * METER_TO_PIX;
		return pos;
	}
	
    public Vector2 toWorld(Vector2 pos){
		pos.x = pos.x * PIX_TO_METER;
		pos.y = pos.y * PIX_TO_METER;
		return pos;
	}
    
    public 	void makeBoundry(Vector2 scr){
		BodyDef bodyDef = new BodyDef();
        bodyDef.type = BodyType.StaticBody;
        FixtureDef fixDef2 = new FixtureDef();
        //fixDef.density = 10.0;                 
        fixDef2.friction = 0.5f;                 
        fixDef2.restitution =0;  
        PolygonShape pol0 = new PolygonShape();
        pol0.setAsBox(10 * PIX_TO_METER / 2, scr.y * PIX_TO_METER);
        PolygonShape pol1 = new PolygonShape();
        pol1.setAsBox(scr.x * PIX_TO_METER/2, 10 * PIX_TO_METER / 2);
        fixDef2.shape = pol0;
        bodyDef.position.set(-5 * PIX_TO_METER, scr.y / 2 * PIX_TO_METER);
        world.createBody(bodyDef).createFixture(fixDef2);
        bodyDef.position.set(scr.x * PIX_TO_METER, scr.y / 2 * PIX_TO_METER);
        world.createBody(bodyDef).createFixture(fixDef2);
        fixDef2.shape = pol1;
        bodyDef.position.set(scr.x / 2 * PIX_TO_METER, scr.y * PIX_TO_METER);
        world.createBody(bodyDef).createFixture(fixDef2);
        bodyDef.position.set(scr.x / 2 * PIX_TO_METER, -5 * PIX_TO_METER);
        world.createBody(bodyDef).createFixture(fixDef2);
	}

}
